home *** CD-ROM | disk | FTP | other *** search
/ Champak Vol A-4 / (Vol A-4) Vol. A4.iso / Games / smashing.swf / scripts / frame_5 / DoAction.as
Text File  |  2008-03-12  |  6KB  |  204 lines

  1. function makePositive(numberToConvert, boolean)
  2. {
  3.    if(boolean)
  4.    {
  5.       if(0 >= numberToConvert)
  6.       {
  7.          numberToConvert = - numberToConvert;
  8.       }
  9.    }
  10.    else if(numberToConvert >= 0)
  11.    {
  12.       numberToConvert = - numberToConvert;
  13.    }
  14.    return numberToConvert;
  15. }
  16. function addPoints(targetMc, points)
  17. {
  18.    if(0 < points)
  19.    {
  20.       totalScore += points;
  21.       menu.txtScore = totalScore;
  22.    }
  23.    if(totalScore >= nextExtraLife)
  24.    {
  25.       sndGrabBonus.start();
  26.       nextExtraLife += extraLifeEveryNPoints;
  27.       padsLeft++;
  28.       menu.txtPadsLeft = padsLeft;
  29.       points = "EXTRA PAD";
  30.    }
  31.    strPoints = new String(points);
  32.    clipCounter++;
  33.    attachMovie("mcShowPoints","mcShowPoints" + clipCounter,clipCounter);
  34.    this["mcShowPoints" + clipCounter].txtPoints1 = points;
  35.    this["mcShowPoints" + clipCounter].txtPoints2 = points;
  36.    this["mcShowPoints" + clipCounter]._x = int(targetMc._x - strPoints.length * 7 / 2);
  37.    this["mcShowPoints" + clipCounter]._y = int(targetMc._y);
  38.    this["mcShowPoints" + clipCounter].play();
  39. }
  40. function keyInput()
  41. {
  42.    if(Key.isDown(80) && keyPressValid && gameInProgress)
  43.    {
  44.       keyPressValid = false;
  45.       if(!gamePaused && keyPressPause < getTimer())
  46.       {
  47.          pauseStatus = showStatus("paused",10000);
  48.          gamePaused = true;
  49.          mcPause.gotoAndPlay("paused");
  50.          keyPressPause = getTimer() + 100;
  51.       }
  52.       else if(keyPressPause < getTimer())
  53.       {
  54.          pauseStatus.play();
  55.          gamePaused = false;
  56.          mcPause.gotoAndStop(1);
  57.          keyPressPause = getTimer() + 100;
  58.       }
  59.    }
  60.    else if(Key.isDown(83) && keyPressValid && !typingPassword)
  61.    {
  62.       keyPressValid = false;
  63.       if(!soundOn && keyPressPause < getTimer())
  64.       {
  65.          globalSound.setVolume(100);
  66.          showStatus("sound on",500);
  67.          soundOn = true;
  68.          keyPressPause = getTimer() + 100;
  69.       }
  70.       else if(keyPressPause < getTimer())
  71.       {
  72.          globalSound.setVolume(0);
  73.          showStatus("sound off",500);
  74.          soundOn = false;
  75.          mcSound.gotoAndPlay("toggleSound");
  76.          keyPressPause = getTimer() + 100;
  77.       }
  78.    }
  79.    else if(!Key.isDown(83) && !Key.isDown(80))
  80.    {
  81.       keyPressValid = true;
  82.    }
  83. }
  84. function showStatus(message, delay)
  85. {
  86.    clipCounter++;
  87.    attachMovie("mcStatus","mcStatus" + clipCounter,clipCounter);
  88.    this["mcStatus" + clipCounter]._x = 320;
  89.    this["mcStatus" + clipCounter]._y = 240;
  90.    this["mcStatus" + clipCounter].txtStatus = message;
  91.    this["mcStatus" + clipCounter].delay = delay;
  92.    statusMcPath = eval(this["mcStatus" + _root.clipCounter]);
  93.    return statusMcPath;
  94. }
  95. function initiateNewLevel()
  96. {
  97.    totalBricks = brickNumber;
  98.    totalBricks -= indestructibleAmount;
  99.    bricksLeft = totalBricks - smashedBricks;
  100.    randomBonusFactor = int(100 / bricksLeft * arrBonuses.length);
  101.    menu.txtBricksLeft = bricksLeft;
  102.    menu.txtLevel = currentLevel;
  103.    menu.txtPadsLeft = padsLeft;
  104.    showStatus("level " + currentLevel,1000);
  105.    gamePaused = false;
  106.    sndPadAppear.start();
  107. }
  108. function cleanClips()
  109. {
  110.    i = 1;
  111.    while(clipCounter >= i)
  112.    {
  113.       mcTarget2 = eval("mcBonusFalling" + i);
  114.       mcTarget3 = eval("mcBall" + i);
  115.       mcTarget2.removeMovieClip();
  116.       mcTarget3.removeMovieClip();
  117.       i++;
  118.    }
  119.    clipCounter = 0;
  120. }
  121. function resetGame()
  122. {
  123.    bricksLeft = 0;
  124.    brickNumber = 0;
  125.    ballsActive = 0;
  126.    smashedBricks = 0;
  127.    indestructibleAmount = 0;
  128.    totalBricks = 0;
  129.    clipCounter = 0;
  130.    totalScore = 0;
  131.    menu.txtBricksLeft = 0;
  132.    menu.txtLevel = 0;
  133.    menu.txtPadsLeft = 0;
  134.    menu.txtScore = 0;
  135. }
  136. function resetLevel()
  137. {
  138.    cleanClips();
  139.    readyToShootBall = false;
  140.    bricksLeft = 0;
  141.    brickNumber = 0;
  142.    ballsActive = 0;
  143.    smashedBricks = 0;
  144.    indestructibleAmount = 0;
  145.    totalBricks = 0;
  146.    clipCounter = 0;
  147. }
  148. arrLevelCode = new Array();
  149. arrLevelCode[0] = "MINICLIP";
  150. arrLevelCode[1] = "BREAKOUT";
  151. arrLevelCode[2] = "FLAMES";
  152. arrLevelCode[3] = "JEWELS";
  153. arrLevelCode[4] = "ZED";
  154. arrLevelCode[5] = "OOP OOP";
  155. arrLevelCode[6] = "KEFRENS";
  156. arrLevelCode[7] = "MB";
  157. arrLevelCode[8] = "FRAME";
  158. arrLevelCode[9] = "BOOM";
  159. arrLevelCode[10] = "INVADE";
  160. arrLevelCode[11] = "WW";
  161. arrLevelCode[12] = "RAF";
  162. arrLevelCode[13] = "WINGS";
  163. arrLevelCode[14] = "CASTLE";
  164. arrLevelCode[15] = "TUBE";
  165. arrLevelCode[16] = "MAGIC";
  166. arrLevelCode[17] = "FENCE";
  167. arrLevelCode[18] = "LIFT";
  168. arrLevelCode[19] = "UFO";
  169. arrLevelCode[20] = "POMPEII";
  170. arrLevelCode[21] = "MAYPOLE";
  171. arrLevelCode[22] = "ROB";
  172. arrLevelCode[23] = "FING";
  173. arrLevelCode[24] = "CLUSTER";
  174. arrLevelCode[25] = "BRICKS";
  175. arrLevelCode[26] = "MAGNETS";
  176. arrLevelCode[27] = "FLOPPY";
  177. arrLevelCode[28] = "BROLLY";
  178. arrLevelCode[29] = "TENNIS";
  179. arrLevelCode[30] = "ZEN";
  180. arrLevelCode[31] = "SVERIGE";
  181. arrLevelCode[32] = "FENG SHUI";
  182. arrLevelCode[33] = "BOMB";
  183. arrLevelCode[34] = "ZED HOUSE";
  184. arrLevelCode[35] = "CAGE";
  185. arrLevelCode[36] = "IGLOO";
  186. arrLevelCode[37] = "REACTION";
  187. arrLevelCode[38] = "LURVE";
  188. arrLevelCode[39] = "BIRA";
  189. arrLevelCode[40] = "NANA";
  190. arrLevelCode[41] = "SAVAGE";
  191. arrLevelCode[42] = "ENGERLUND";
  192. arrLevelCode[43] = "TOTEBO";
  193. arrLevelCode[44] = "PONG";
  194. arrLevelCode[45] = "BORE";
  195. arrLevelCode[46] = "CATCH";
  196. arrLevelCode[47] = "GEEGEE";
  197. arrLevelCode[48] = "COPPERTOP";
  198. arrLevelCode[49] = "FULL-TIME";
  199. arrLevelCode[50] = "ROBSTER";
  200. soundOn = true;
  201. extraLifeEveryNPoints = 20000;
  202. nextExtraLife = extraLifeEveryNPoints;
  203. scoreTimer = getTimer();
  204.